package edu.nyu.hps.assignment1;

import java.io.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException{
		Double n = 0.0;
		boolean trueInput = true;

		while (trueInput) {
			System.out.print("Please Enter N: ");
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));
			try {
				String inputN = br.readLine();
				n = Double.valueOf(inputN.trim()).doubleValue();
				trueInput = false;
			} catch (Exception io) {
				System.out.println("Incorrect input. N should be a double.");
				trueInput = true;
			}
		}
		trueInput = false;
		System.out.println("The output is..");
		System.out.println();
		MintProblem mp = new MintProblem(n);
		double time = System.currentTimeMillis();
		mp.computeWeigthedAverage();

		System.out.println("**************Exact Change**************");
		System.out.print("The Best Coinset is: [ ");
		int temp[] = mp.getCoinSet1().clone();
		for (int i = 0; i < temp.length - 1; i++)
			System.out.print(temp[i] + " ");
		System.out.println("]");
		System.out.println("Weigthed Average is: " + mp.getExactChangeAvg());
		System.out.println();

		System.out.println("**************Smallest Change**************");
		System.out.print("The Best Coinset is: [ ");
		temp = mp.getCoinSet2().clone();
		for (int i = 0; i < temp.length - 1; i++)
			System.out.print(temp[i] + " ");
		System.out.println("]");
		System.out.println("Weigthed Average is: " + mp.getSmallChangeAvg());
		System.out.println("The total coins are" + (mp.getTotal1() + mp.getTotal2()));
		System.out.println();
		System.out.println("The total time of execution is : "
				+ (System.currentTimeMillis() - time)/1000 + " seconds");
	}
}
